<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>std_b00001.vtc</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (Varnish Test Case language) - Theme (Breeze Light)"/>
</head><body style="background-color:#ffffff;color:#1f1c1b"><pre>
<span style="font-weight:bold;">varnishtest</span> <span style="color:#bf0303;">&quot;Test std.random()&quot;</span>

<span style="font-weight:bold;">server</span> <span style="color:#0095ff;text-decoration:underline;">s1</span><span style="color:#bf0303;"> </span>{
	<span style="font-weight:bold;">rxreq</span>
	<span style="font-weight:bold;">txresp</span>
} <span style="font-weight:bold;">-start</span>

<span style="font-weight:bold;">varnish</span> <span style="color:#0095ff;text-decoration:underline;">v1</span><span style="font-weight:bold;"> -vcl+backend</span> {
	<span style="font-weight:bold;">import</span> <span style="color:#0057ae;font-weight:bold;">std</span>;

	<span style="font-weight:bold;">sub</span> <span style="color:#644a9b;font-weight:bold;">vcl_deliver</span> {
		<span style="font-weight:bold;">set</span> <span style="color:#0095ff;">resp.http.rnd1</span> <span style="color:#006e28;">=</span> <span style="color:#0057ae;">std.random</span>(<span style="color:#b08000;">0</span>, <span style="color:#b08000;">1</span>);
		<span style="font-weight:bold;">set</span> <span style="color:#0095ff;">resp.http.rnd2</span> <span style="color:#006e28;">=</span> <span style="color:#0057ae;">std.random</span>(<span style="color:#b08000;">0</span>, <span style="color:#b08000;">10</span>);
		<span style="font-weight:bold;">set</span> <span style="color:#0095ff;">resp.http.rnd3</span> <span style="color:#006e28;">=</span> <span style="color:#0057ae;">std.random</span>(<span style="color:#b08000;">8</span>, <span style="color:#b08000;">10</span>);
		<span style="font-weight:bold;">set</span> <span style="color:#0095ff;">resp.http.rnd4</span> <span style="color:#006e28;">=</span> <span style="color:#0057ae;">std.random</span>(<span style="color:#b08000;">99</span>, <span style="color:#b08000;">100</span>);
	}
} <span style="font-weight:bold;">-start</span>

<span style="font-weight:bold;">varnish</span> <span style="color:#0095ff;text-decoration:underline;">v1</span> <span style="font-weight:bold;">-cliok </span><span style="color:#bf0303;">&quot;debug.srandom&quot;</span>

<span style="font-weight:bold;">client</span> <span style="color:#0095ff;text-decoration:underline;">c1</span><span style="color:#bf0303;"> </span>{
	<span style="font-weight:bold;">txreq</span>
	<span style="font-weight:bold;">rxresp</span>
	<span style="font-weight:bold;">expect</span> <span style="color:#0095ff;">resp.http.rnd1</span> <span style="color:#006e28;">==</span> <span style="color:#b08000;">0.656</span>
	<span style="font-weight:bold;">expect</span> <span style="color:#0095ff;">resp.http.rnd2</span> <span style="color:#006e28;">==</span> <span style="color:#b08000;">0.390</span>
	<span style="font-weight:bold;">expect</span> <span style="color:#0095ff;">resp.http.rnd3</span> <span style="color:#006e28;">==</span> <span style="color:#b08000;">8.585</span>
	<span style="font-weight:bold;">expect</span> <span style="color:#0095ff;">resp.http.rnd4</span> <span style="color:#006e28;">==</span> <span style="color:#b08000;">99.636</span>
} <span style="font-weight:bold;">-run</span>
</pre></body></html>
